import request from '@/utils/request'
import qs from 'qs'

// 分页查询套餐列表
export const reqGetSetmealPage = (params) => {
  return request.get('/setmeal/page', {
    params
  })
}

//新增套餐
export const reqAddSetmeal = (data) => {
  return request.post('/setmeal', data)
}

//根据id获取套餐数据，含菜品
export const reqGetSetmealById = (id) => {
  return request.get(`/setmeal/${id}`)
}

//修改套餐
export const reqUpdateSetmeal = (data) => {
  return request.put('/setmeal/', data)
}

//删除套餐（逻辑删除）
export const reqDeleteSetmealBatch = (ids) => {
  return request.delete('/setmeal', {
    params: {
      ids: ids
    }
  })
}

//修改状态
export const reqUpdateSetmealStatusBatch = (status, ids) => {
  // axios的post/patch请求方式，怎么把参数直接加在URL后面，不用payload
  // 相关帮助：https://apifox.com/apiskills/axios-post-request/
  return request.post(
    `/setmeal/status/${status}`,
    qs.stringify({ ids: ids }, { indices: false })
  )
}
